package com.qingfeng.client.util;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.qingfeng.base.model.Page;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangyuefei
 * @version 1.0
 * @date 2020/2/10 12:39 下午
 */
public class PageOld implements Serializable {
    private int pageNo = 1;
    private int pageSize = 20;
    private int totalRows = 0;
    private String sortname;
    private String sortorder;

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalRows() {
        return totalRows;
    }

    public void setTotalRows(int totalRows) {
        this.totalRows = totalRows;
    }

    public String getSortname() {
        return sortname;
    }

    public void setSortname(String sortname) {
        this.sortname = sortname;
    }

    public String getSortorder() {
        return sortorder;
    }

    public void setSortorder(String sortorder) {
        this.sortorder = sortorder;
    }

    public Page toPage(){
        Page page = new Page();
        page.setPageNum(this.pageNo);
        page.setPageSize(this.pageSize);
        page.setTotal(this.totalRows);
        OrderItem orderItem = new OrderItem();
        orderItem.setColumn(this.getSortname());
        if (this.getSortorder().toUpperCase().equals("asc")){
            orderItem.setAsc(true);
        }else {
            orderItem.setAsc(false);
        }
        List<OrderItem> list = new ArrayList<>();
        list.add(orderItem);
        page.setOrders(list);
        return page;
    }
}
